#include<bits/stdc++.h>

using namespace std;


double f(double x) {
    return x;

}

//通用的定积分
double integrate(double f(double), double a, double b) {
    double dx = (b - a) / 100;
    double tot = 0;
    for (int i = 0; i < 100; i++) {
        double top = f(a + i * dx);
        double bottom = f(a + (i + 1) * dx);
        double h = dx;
        tot += (top + bottom) * h / 2;

    }
    return tot;
}


int main() {
    cout << integrate(f, 0, 1) << endl;
    cout << integrate(sin, 0, 1) << endl;
    cout << integrate(cos, 0, 1) << endl;

    return 0;
}
